﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Data;
using System.Xml;
using System.IO;
using System.Text;

namespace ProjectSem3
{
    public partial class WebForm12 : System.Web.UI.Page
    {
        private dataDataContext dc = new dataDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            string url = Convert.ToString(Request.QueryString["url"]);
            string content = GetHTML(url);
            int t = 0;
            int b = 0;
            t = content.IndexOf("<h1 class=\"title\"");
            if (t > 0)
                content = content.Substring(t + 18, content.Length - t - 18);
            b = content.LastIndexOf("id=\"shareleft\"");
            content = content.Substring(0, b - 80);
            content = content.Replace("http://www.technewsworld.com/rsstory/", "News_Detail.aspx?url=http://www.technewsworld.com/rsstory/");
            content = content.Replace("/rsstory/", "News_Detail.aspx?url=http://www.technewsworld.com/rsstory/");
            content = content.Replace("/images","http://www.technewsworld.com/images");
            Label1.Text = content;





        }

        public string GetHTML(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return "";
            }
            string HTML = "";
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();


            Stream responsestream = response.GetResponseStream();
            StreamReader reader = new StreamReader(responsestream, Encoding.UTF8);
            HTML = reader.ReadToEnd();
            response.Close();
            reader.Close();
            return HTML;
        }


       
    }
}